﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelixSoftware.Azure.MethodExecutionServices
{
    public abstract class MethodExecutionProxy
    {
        public void Execute(Action method)
        {
            this.Execute((Delegate)method);
        }

        public void Execute<T>(Action<T> method, T arg)
        {
            this.Execute((Delegate)method, arg);
        }

        public void Execute<T1, T2>(Action<T1, T2> method, T1 arg1, T2 arg2)
        {
            this.Execute((Delegate)method, arg1, arg2);
        }

        public void Execute<T1, T2, T3>(Action<T1, T2, T3> method, T1 arg1, T2 arg2, T3 arg3)
        {
            this.Execute((Delegate)method, arg1, arg2, arg3);
        }

        public void Execute<T1, T2, T3, T4>(Action<T1, T2, T3, T4> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            this.Execute((Delegate)method, arg1, arg2, arg3, arg4);
        }

        public TResult Execute<TResult>(Func<TResult> method)
        {
            return (TResult)this.Execute((Delegate)method);
        }

        public TResult Execute<T, TResult>(Func<T, TResult> method, T arg)
        {
            return (TResult)this.Execute((Delegate)method, arg);
        }

        public TResult Execute<T1, T2, TResult>(Func<T1, T2, TResult> method, T1 arg1, T2 arg2)
        {
            return (TResult)this.Execute((Delegate)method, arg1, arg2);
        }

        public TResult Execute<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> method, T1 arg1, T2 arg2, T3 arg3)
        {
            return (TResult)this.Execute((Delegate)method, arg1, arg2, arg3);
        }

        public TResult Execute<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
        {
            return (TResult)this.Execute((Delegate)method, arg1, arg2, arg3, arg4);
        }

        public abstract object Execute(Delegate method, params object[] args);
    }
}
